<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>18_正则表达式-数量修饰符</title>
    </head>
    <body>
        <script>
            // 3. {n} 正好出现n次
            var reg = /^[a-z]{3}$/;
            console.log(reg.test('af'));
            console.log(reg.test('aff'));
            console.log(reg.test('afff'));

            // 4. {m,n} 出现m-n次
            var reg = /^[a-z]{6,8}$/;
            console.log(reg.test('abcde'));
            console.log(reg.test('abcdef'));
            console.log(reg.test('abcdeff'));

            // 5. {m,} m次以上
            var reg = /^[a-z]{5,}$/;
            console.log(reg.test('abcd'));
            console.log(reg.test('abcdd'));
            console.log(reg.test('abcdfdfd'));


            // 6. + 至少一个，相当于{1,}
            var reg = /[a-z]+/;
            console.log(reg.test('12312321'));
            console.log(reg.test('fdffdafdfdsfdsf123123213213123sfdsf'));

            // 7. * 0个或多个，相当于{0,}
            var reg = /[a-z]*/;
            console.log(reg.test('32132132fdsfdsfds1'));


            // 8. ? 0个或1个，相当于{0,1}
            var reg = /^[a-z]?$/;
            // console.log(reg.test('1231ffdsfdsf2312'));
            console.log(reg.test('1231f12'));
        </script>
    </body>
</html>